#!/bin/bash

if [ "$1" = "" ]
then
	echo "
Boxbg is a lightweight wallpaper script, it uses feh to manage wallpaper on your desktop.

Usage: background.jpg --bg-scale
       restore
"
else



if [ "$1" = "restore" ]
then
	if [ -f ~/.boxbg ]
	then

		# load params
		params=`cat ~/.boxbg`

		# set background
		`$params`

		echo "Restoring old background, executing $params"

	else
		echo "Nothing to restore, cant find ~/.boxbg"
	fi
else

if [ -f "$1" ]
then
	
	# check if ~/.boxbg file exists
	if [ -f ~/.boxbg ]
	then
		rm ~/.boxbg
	fi


	touch ~/.boxbg
	echo "feh $2 $1" > ~/.boxbg
	echo "Background changed."
	feh "$2" "$1"
else
	echo "Cant find background image $1, is it correct?"
fi
fi
fi
